
import React from "react";


class Clock extends React.Component {
    constructor(props) {
        super(props);
        this.timer = null;
        this.state = {
          currentTime: new Date()
        };
      }
    
      componentDidMount() {
        this.timer = setInterval(() => {
          this.setState({
            currentTime: new Date()
          });
        }, 5000);
      }
    
      componentWillUnmount() {
        clearInterval(this.timer);
      }
    
      render() {
        const { currentTime } = this.state;
        return (
          <div>
            <p>currentTime: {currentTime.toLocaleTimeString()}</p>
          </div>
        );
      }
  }

  export default Clock;